package com.qf.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.qf.bean.Training;
import com.qf.dao.TrainingMapper;
import com.qf.service.FuHeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * IntelliJ IDEA -> person
 * 2019/11/23 9:12
 *
 * @author zmyao
 * 别看，我是渣渣。
 */
@Service
public class FuHeServiceImpl implements FuHeService {
    @Autowired
    private TrainingMapper trainingMapper;
    @Override
    public int updateByIdSetAuditopinion(int id, String auditopinion) {
        HashMap map = new HashMap();
        map.put("id",id);
        map.put("auditopinion",auditopinion);
        return trainingMapper.updateByIdSetAuditopinion(map) ;
    }

    @Override
    public PageInfo<Training> findAllByOpintion(int pageIndex, int pageSize, String trainingname, String trainingdateStart, String  trainingdateEnd,String auditopinion) {
        PageHelper.startPage(pageIndex,pageSize);
        Map map = new HashMap();
        map.put("trainingname",trainingname);
        map.put("trainingdateStart",trainingdateStart);
        map.put("trainingdateEnd",trainingdateEnd);
        map.put("auditopinion",auditopinion);
        List<Training> fuhes= trainingMapper.findall(map);
        PageInfo<Training> pageInfo = new PageInfo<>(fuhes);
        return pageInfo;
    }

    @Override
    public Training findTrainingByIdOpinion(Integer id,String auditopinion) {
        System.out.println(id+","+auditopinion);
       Map  map = new HashMap<>();
        map.put("id",id);
        map.put("auditopinion",auditopinion);
        return trainingMapper.findTrainingByIdOpinion(map);
    }

    @Override
    public int updateOpintion(Training training, String auditopinion) {
        System.out.println("trainingresult"+training.getTrainingresult());
        training.setAuditopinion(auditopinion);
        return trainingMapper.updateByPrimaryKeySelective(training);
    }

}
